<template>
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
        <el-form-item label="预约人" prop="name">
            <el-input v-model="ruleForm.name" style="width:23%;"></el-input>
        </el-form-item>
        <el-form-item label="预约部门" prop="department">
            <el-select v-model="ruleForm.department" clearable placeholder="请选择部门">
                <el-option label="研发部" value="department1"></el-option>
                <el-option label="市场部" value="department2"></el-option>
            </el-select>
        </el-form-item>
        <el-form-item label="会议室" prop="room">
            <el-select v-model="ruleForm.room" clearable placeholder="请选择会议室">
                <el-option label="庐山" value="room1"></el-option>
                <el-option label="嵩山" value="room2"></el-option>
            </el-select>
        </el-form-item>
        <el-form-item label="会议主题" prop="theme">
            <el-input v-model="ruleForm.theme" style="width:46%;"></el-input>
        </el-form-item>
        <el-form-item label="会议时间" required>
            <el-col :span="5">
                <el-form-item prop="date">
                    <el-date-picker type="date" placeholder="选择日期" v-model="ruleForm.date" style="width: 100%;"></el-date-picker>
                </el-form-item>
            </el-col>
            <!-- <el-col class="line" :span="2">-</el-col>-->
            <el-col :span="5" style="margin-left:45px;">
                <el-form-item prop="time" >
                    <!--<el-time-picker type="fixed-time" placeholder="选择时间" v-model="ruleForm.date2" style="width: 100%;">

                    </el-time-picker>-->
                    <el-time-picker is-range v-model="ruleForm.time " range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" placeholder="选择时间范围" value-format="HH:mm" format="HH:mm">
                    </el-time-picker>
                </el-form-item>
            </el-col>
        </el-form-item>
        <!--<el-form-item label="即时配送" prop="delivery">
          <el-switch v-model="ruleForm.delivery"></el-switch>
        </el-form-item>-->
        <el-form-item label="设备需求" prop="type">
            <el-checkbox-group v-model="ruleForm.type">
                <el-checkbox label="激光笔" name="type"></el-checkbox>
                <el-checkbox label="八爪鱼" name="type"></el-checkbox>
                <el-checkbox label="投影仪" name="type"></el-checkbox>
                <el-checkbox label="电视" name="type"></el-checkbox>
            </el-checkbox-group>
        </el-form-item>
        <!--<el-form-item label="特殊资源" prop="resource">
          <el-radio-group v-model="ruleForm.resource">
            <el-radio label="线上品牌商赞助"></el-radio>
            <el-radio label="线下场地免费"></el-radio>
          </el-radio-group>
        </el-form-item>-->
        <el-form-item label="备注" prop="remark">
            <el-input type="textarea" v-model="ruleForm.remark" style="width:46%;"></el-input>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
            <el-button @click="resetForm('ruleForm')">重置</el-button>
        </el-form-item>
    </el-form>
</template>
<script>
    export default {
        data() {
            return {
                ruleForm: {
                    name: '',
                    department: '',
                    date: '',
                    time: '',
                    /* delivery: false,*/
                    type: [],
                    remark: '',
                    room:'',
                    theme:''
                },
                rules: {
                    name: [
                        { required: true, message: '请输入预约人', trigger: 'blur' },
                        /* { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }*/
                    ],
                    department: [
                        { required: true, message: '请选择部门', trigger: 'change' }
                    ],
                    room: [
                        { required: true, message: '请选择会议室', trigger: 'change' }
                    ],
                    theme: [
                        { required: true, message: '请输入会议主题', trigger: 'change' }
                    ],
                    date: [
                        { type: 'date', required: true, message: '请选择日期', trigger: 'change' }
                    ],
                    time: [
                        { type: 'date', required: true, message: '请选择时间范围', trigger: 'change' }
                    ],
                    /* type: [
                         { type: 'array', required: true, message: '请至少选择一个活动性质', trigger: 'change' }
                     ],*/
                    /* resource: [
                         { required: true, message: '请选择活动资源', trigger: 'change' }
                     ],*/
                    /*  remark: [
                          { required: true, message: '请填写备注', trigger: 'blur' }
                      -----------------------------------------------------------------------------------------------------------------------------]*/
                }
            };
        },
        methods: {
            submitForm(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        alert('submit!');
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            },
            resetForm(formName) {
                this.$refs[formName].resetFields();
            }
        }
    }
</script>